home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-01 | 1.8 KB | 83 lines | [TEXT/CWIE] |
- unit MyBarcodes;
-
- interface
-
- uses
- Types;
-
- const
- narrowLineWidth = 1;
- wideLineWidth = 3 * narrowLineWidth;
- barCodeWidth = (3 * wideLineWidth) + (7 * narrowLineWidth);
- barCodeHeight = 18;
- alphaHeight = 10;
-
- procedure DrawBarCodeStr (theStr: Str255; var h:integer; v: integer; alpha: boolean);
- procedure DrawBarCodeChar (theChar: char; var h:integer; v: integer; alpha: boolean);
-
- implementation
-
- uses
- Quickdraw,Resources;
-
- procedure DrawBarCodeStr (theStr: Str255; var h:integer; v: integer; alpha: boolean);
- var
- i: integer;
- begin
- for i := 1 to length(theStr) do begin
- DrawBarCodeChar(theStr[i], h, v, alpha);
- end;
- end;
-
- procedure DrawBarCodeChar (theChar: char; var h:integer; v: integer; alpha: boolean);
-
- procedure White (width: integer);
- begin
- h := h + width;
- end;
-
- procedure Black (width: integer);
- begin
- PenSize(width, 1);
- MoveTo(h, v);
- LineTo(h, v + barCodeHeight);
- h := h + width;
- end;
-
- type
- CodeData = array[0..127] of longint;
- CodeDataPtr = ^CodeData;
- CodeDataHandle = ^CodeDataPtr;
- var
- codes: CodeDataHandle;
- n: longint;
- i, m: integer;
- begin
- codes := CodeDataHandle(GetResource('BARC', 128));
- if ('a'<=theChar) & (theChar<='z') then begin
- theChar := chr(ord(theChar)-$20);
- end;
- if (codes <> nil) & (ord(theChar) <= 127) & (codes^^[ord(theChar)] <> -1) then begin
- n := codes^^[ord(theChar)];
- for i := 8 downto 0 do begin
- m := BAND(BSR(n, i * 2), $03);
- case m of
- 0:
- White(narrowLineWidth);
- 1:
- White(wideLineWidth);
- 2:
- Black(narrowLineWidth);
- 3:
- Black(wideLineWidth);
- end;
- end;
- White(narrowLineWidth);{White space between barcodes}
- if alpha then begin
- MoveTo(h - (3 * (barCodeWidth div 4)), v + barCodeHeight + 11);
- drawChar(theChar);
- end;
- end;
- end;
- end.
-